home *** CD-ROM | disk | FTP | other *** search
/ Whiteline: delta / whiteline CD Series - delta.iso / tex / tools / dvi_300b / treiber / sources / mintbind.h < prev    next >
C/C++ Source or Header  |  1995-11-25  |  9KB  |  267 lines

  1. #ifndef _MINTBIND_H
  2. #define _MINTBIND_H
  3.  
  4. #ifdef __TURBOC__
  5. # ifndef __TOS
  6. #  include <tos.h>
  7. # endif
  8. #else
  9. #ifndef _OSBIND_H
  10. #include <osbind.h>
  11. #endif
  12. #endif
  13.  
  14. #ifdef __GNUC_INLINE__
  15. #define trap_1_wwlw(n, a, b, c)                        \
  16. ({                                    \
  17.     register long retvalue __asm__("d0");                \
  18.     short _a = (short)(a);                        \
  19.     long  _b = (long) (b);                        \
  20.     short  _c = (short) (c);                    \
  21.                                         \
  22.     __asm__ volatile                        \
  23.     ("\
  24.         movw    %4,sp@-; \
  25.         movl    %3,sp@-; \
  26.         movw    %2,sp@-; \
  27.         movw    %1,sp@-; \
  28.         trap    #1;    \
  29.         addw    #10,sp "                    \
  30.     : "=r"(retvalue)            /* outputs */        \
  31.     : "g"(n), "r"(_a), "r"(_b), "r"(_c)     /* inputs  */        \
  32.     : "d0", "d1", "d2", "a0", "a1", "a2"    /* clobbered regs */    \
  33.     );                                \
  34.     retvalue;                            \
  35. })
  36.  
  37. #define trap_1_wwww(n, a, b, c)                        \
  38. ({                                    \
  39.     register long retvalue __asm__("d0");                \
  40.     short _a = (short)(a);                        \
  41.     short  _b = (short)(b);                        \
  42.     short  _c = (short)(c);                        \
  43.                                         \
  44.     __asm__ volatile                        \
  45.     ("\
  46.         movw    %4,sp@-; \
  47.         movw    %3,sp@-; \
  48.         movw    %2,sp@-; \
  49.         movw    %1,sp@-; \
  50.         trap    #1;    \
  51.         addw    #10,sp "                    \
  52.     : "=r"(retvalue)            /* outputs */        \
  53.     : "g"(n), "r"(_a), "r"(_b), "r"(_c)     /* inputs  */        \
  54.     : "d0", "d1", "d2", "a0", "a1", "a2"    /* clobbered regs */    \
  55.     );                                \
  56.     retvalue;                            \
  57. })
  58.  
  59. #define trap_1_wwl(n, a, b)                        \
  60. ({                                    \
  61.     register long retvalue __asm__("d0");                \
  62.     short _a = (short)(a);                        \
  63.     long  _b = (long) (b);                        \
  64.                                         \
  65.     __asm__ volatile                        \
  66.     ("\
  67.         movl    %3,sp@-; \
  68.         movw    %2,sp@-; \
  69.         movw    %1,sp@-; \
  70.         trap    #1;    \
  71.         addw    #8,sp "                        \
  72.     : "=r"(retvalue)            /* outputs */        \
  73.     : "g"(n), "r"(_a), "r"(_b)        /* inputs  */        \
  74.     : "d0", "d1", "d2", "a0", "a1", "a2"    /* clobbered regs */    \
  75.     );                                \
  76.     retvalue;                            \
  77. })
  78.  
  79. #else
  80.  
  81. #ifdef __GNUC__
  82. # ifndef __MSHORT__
  83. #  define __LONG_TRAPS__
  84. # endif
  85. #endif
  86.  
  87. #ifndef __LONG_TRAPS__
  88. # ifndef trap_1_w
  89. #  define trap_1_w(n)        gemdos(n)
  90. #  define trap_1_wl(n,a)        gemdos(n, (long)(a))
  91. #  define trap_1_wll(n, a, b)    gemdos(n, (long)(a), (long)(b))
  92. #  define trap_1_ww(n,a)        gemdos(n, a)
  93. #  define trap_1_www(n,a,b)    gemdos(n, a, b)
  94. #  define trap_1_wwlll(n,a,b,c,d) gemdos(n, a, (long)(b), (long)(c), (long)(d))
  95. #  define trap_1_wwll(n, a, b, c)    gemdos(n, a, (long)(b), (long)(c))
  96. #  define trap_1_wlw(n, a, b)    gemdos(n, (long)(a), b)
  97. #  define trap_1_wlww(n, a, b, c)    gemdos(n, (long)(a), b, c)
  98. #  define trap_13_w(n)        bios(n)
  99. #  define trap_14_w(n)        xbios(n)
  100. # endif
  101. # define trap_1_wwlw(n,a,b,c)    gemdos(n, a, (long)(b), c)
  102. # define trap_1_wwww(n,a,b,c)    gemdos(n, a, b, c)
  103. # define trap_1_wwl(n, a, b)    gemdos(n, a, (long)(b))
  104. #endif /* __LONG_TRAPS__ */
  105.  
  106. #endif /* __GNUC_INLINE__ */
  107.  
  108. /* note: none of these functions is declared as (void), despite
  109.  * what the man pages say; this is so that programs can check
  110.  * for a -32 return error from TOS if MiNT is not installed
  111.  */
  112.  
  113. #define    Syield()                        \
  114.         (short)trap_1_w(0xff)
  115. #define Fpipe(ptr)                        \
  116.         (short)trap_1_wl(0x100, (long)(ptr))
  117. #define Fcntl(f, arg, cmd)                    \
  118.         trap_1_wwlw(0x104, (short)(f), (long)(arg), (short)(cmd))
  119. #define Finstat(f)                        \
  120.         trap_1_ww(0x105, (short)(f))
  121. #define Foutstat(f)                        \
  122.         trap_1_ww(0x106, (short)(f))
  123. #define Fgetchar(f, mode)                    \
  124.         trap_1_www(0x107, (short)(f), (short)(mode))
  125. #define Fputchar(f, ch, mode)                    \
  126.         trap_1_wwlw(0x108, (short)(f), (long)(ch), (short)(mode))
  127.  
  128. #define Pwait()                            \
  129.         trap_1_w(0x109)
  130. #define Pnice(delta)                        \
  131.         (short)trap_1_ww(0x10a, (short)(delta))
  132. #define Pgetpid()                        \
  133.         (short)trap_1_w(0x10b)
  134. #define Pgetppid()                        \
  135.         (short)trap_1_w(0x10c)
  136. #define Pgetpgrp()                        \
  137.         (short)trap_1_w(0x10d)
  138. #define Psetpgrp(pid, grp)                    \
  139.         (short)trap_1_www(0x10e, (short)(pid), (short)(grp))
  140. #define Pgetuid()                        \
  141.         (short)trap_1_w(0x10f)
  142. #define Psetuid(id)                        \
  143.         (short)trap_1_ww(0x110, (short)(id))
  144. #define Pkill(pid, sig)                        \
  145.         (short)trap_1_www(0x111, (short)(pid), (short)(sig))
  146. #define Psignal(sig, handler)                    \
  147.         trap_1_wwl(0x112, (short)(sig), (long)(handler))
  148. #define Pvfork()                        \
  149.         (short)trap_1_w(0x113)
  150. #define Pgetgid()                        \
  151.         (short)trap_1_w(0x114)
  152. #define Psetgid(id)                        \
  153.         (short)trap_1_ww(0x115, (short)(id))
  154. #define Psigblock(mask)                        \
  155.         trap_1_wl(0x116, (unsigned long)(mask))
  156. #define Psigsetmask(mask)                    \
  157.         trap_1_wl(0x117, (unsigned long)(mask))
  158. #define Pusrval(arg)                        \
  159.         trap_1_wl(0x118, (long)(arg))
  160. #define Pdomain(arg)                        \
  161.         (short)trap_1_ww(0x119, (short)(arg))
  162. #define Psigreturn()                        \
  163.         (short)trap_1_w(0x11a)
  164. #define Pfork()                            \
  165.         (short)trap_1_w(0x11b)
  166. #define Pwait3(flag, rusage)                    \
  167.         trap_1_wwl(0x11c, (short)(flag), (long)(rusage))
  168. #define Fselect(time, rfd, wfd, xfd)                \
  169.         (short)trap_1_wwlll(0x11d, (unsigned short)(time), (long)(rfd), \
  170.                 (long)(wfd), (long)(xfd))
  171. #define Prusage(rsp)                        \
  172.         (short)trap_1_wl(0x11e, (long)(rsp))
  173. #define Psetlimit(i, val)                    \
  174.         trap_1_wwl(0x11f, (short)(i), (long)(val))
  175.  
  176. #define Talarm(sec)                        \
  177.         trap_1_wl(0x120, (long)(sec))
  178. #define Pause()                            \
  179.         (short)trap_1_w(0x121)
  180. #define Sysconf(n)                        \
  181.         trap_1_ww(0x122, (short)(n))
  182. #define Psigpending()                        \
  183.         trap_1_w(0x123)
  184. #define Dpathconf(name, which)                    \
  185.         trap_1_wlw(0x124, (long)(name), (short)(which))
  186.  
  187. #define Pmsg(mode, mbox, msg)                    \
  188.         trap_1_wwll(0x125, (short)(mode), (long)(mbox), (long)(msg))
  189. #define Fmidipipe(pid, in, out)                    \
  190.         trap_1_wwww(0x126, (short)(pid), (short)(in),(short)(out))
  191. #define Prenice(pid, delta)                    \
  192.         (short)trap_1_www(0x127, (short)(pid), (short)(delta))
  193. #define Dopendir(name, flag)                    \
  194.         trap_1_wlw(0x128, (long)(name), (short)(flag))
  195. #define Dreaddir(len, handle, buf)                \
  196.         trap_1_wwll(0x129, (short)(len), (long)(handle), (long)(buf))
  197. #define Drewinddir(handle)                    \
  198.         trap_1_wl(0x12a, (long)(handle))
  199. #define Dclosedir(handle)                    \
  200.         trap_1_wl(0x12b, (long)(handle))
  201. #define Fxattr(flag, name, buf)                    \
  202.         trap_1_wwll(0x12c, (short)(flag), (long)(name), (long)(buf))
  203. #define Flink(old, new)                        \
  204.         trap_1_wll(0x12d, (long)(old), (long)(new))
  205. #define Fsymlink(old, new)                    \
  206.         trap_1_wll(0x12e, (long)(old), (long)(new))
  207. #define Freadlink(siz, buf, linknm)                \
  208.         trap_1_wwll(0x12f, (short)(siz), (long)(buf), (long)(linknm))
  209. #define Dcntl(cmd, name, arg)                    \
  210.         trap_1_wwll(0x130, (short)(cmd), (long)(name), (long)(arg))
  211. #define Fchown(name, uid, gid)                    \
  212.         trap_1_wlww(0x131, (long)(name), (short)(uid), (short)(gid))
  213. #define Fchmod(name, mode)                    \
  214.         trap_1_wlw(0x132, (long)(name), (short)(mode))
  215. #define Pumask(mask)                        \
  216.         (short)trap_1_ww(0x133, (short)(mask))
  217. #define Psemaphore(mode, id, tmout)                \
  218.         trap_1_wwll(0x134, (short)(mode), (long)(id), (long)(tmout))
  219. #define Dlock(mode, drive)                    \
  220.         trap_1_www(0x135, (short)(mode), (short)(drive))
  221. #define Psigpause(mask)                        \
  222.         (short)trap_1_wl(0x136, (unsigned long)(mask))
  223. #define Psigaction(sig, act, oact)                \
  224.         trap_1_wwll(0x137, (short)(sig), (long)(act), (long)(oact))
  225. #define Pgeteuid()                        \
  226.         (short)trap_1_w(0x138)
  227. #define Pgetegid()                        \
  228.         (short)trap_1_w(0x139)
  229.  
  230. #define SHMGETBLK    (('M'<< 8) | 0)
  231. #define SIGUSR1 29
  232. #define SIG_IGN (void*)1L
  233.  
  234. #define O_RWMODE      0x03    /* isolates file read/write mode */
  235. #    define O_RDONLY    0x00
  236. #    define O_WRONLY    0x01
  237. #    define O_RDWR    0x02
  238. #    define O_EXEC    0x03    /* execute file; used by kernel only */
  239.  
  240. #define O_APPEND    0x08    /* all writes go to end of file */
  241.  
  242. #define O_SHMODE    0x70    /* isolates file sharing mode */
  243. #    define O_COMPAT    0x00    /* compatibility mode */
  244. #    define O_DENYRW    0x10    /* deny both read and write access */
  245. #    define O_DENYW    0x20    /* deny write access to others */
  246. #    define O_DENYR    0x30    /* deny read access to others */
  247. #    define O_DENYNONE 0x40    /* don't deny any access to others */
  248.  
  249. #define O_NOINHERIT    0x80    /* children don't get this file descriptor */
  250.  
  251. #define O_NDELAY    0x100    /* don't block for i/o on this file */
  252. #define O_CREAT        0x200    /* create file if it doesn't exist */
  253. #define O_TRUNC        0x400    /* truncate file to 0 bytes if it does exist */
  254. #define O_EXCL        0x800    /* fail open if file exists */
  255.  
  256. #define O_USER        0x0fff    /* isolates user-settable flag bits */
  257.  
  258. #define O_GLOBAL    0x1000    /* for Fopen: opens a global file handle */
  259.  
  260. /* kernel mode bits -- the user can't set these! */
  261. #define O_TTY        0x2000    /* FILEPTR refers to a terminal */
  262. #define O_HEAD        0x4000    /* FILEPTR is the master side of a fifo */
  263. #define O_LOCK        0x8000    /* FILEPTR has had locking Fcntl's performed */
  264.  
  265.  
  266. #endif /* _MINTBIND_H */
  267.